#ifndef SLIDERLISTWIDGET_H
#define SLIDERLISTWIDGET_H

#include <QWidget>
#include <QList>
#include <QToolButton>

namespace Ui {
class SliderListWidget;
}

class SliderListWidget : public QWidget
{
    Q_OBJECT

public:
    static const int WIDTH_LARGE = 312/2;
    static const int HEIGHT_LARGE = 376/2;

    static const int WIDTH_MIDDLE = 240/2;
    static const int HEIGHT_MIDDLE = 310/2;

    static const int WIDTH_SMALL = 200/2;
    static const int HEIGHT_SMALL = 286/2;

    static const int WIDTH_MIX = 20/2;

    static const int ACTIVE_BUTTON_SIZE = 5;

public:
    explicit SliderListWidget(QWidget *parent = 0);
    ~SliderListWidget();

    int count();

    int currentIndex();

    QToolButton* currentButton();

    void next();

    void prev();

public slots:
    void setCurrentIndex(int index);

signals:
    void currentChanged(int index);

private:
    Ui::SliderListWidget *ui;


    struct ButtonImageSet
    {
        QString large;
        QString middle;
        QString small;

        ButtonImageSet()
        {
        }

        ButtonImageSet(const char* large, const char* middle, const char* small)
        {
            this->large = large;
            this->middle = middle;
            this->small = small;
        }

        QString get(int type)
        {
            int value = abs(type);
            if (value == 0)
            {
                return large;
            }
            else if (value == 1)
            {
                return middle;
            }
            return small;
        }
    };

protected:
    void setupUI();

    void activeButton(int index);

    int getDistance(int y, int target, int size);

    void makeRects();
    QRect makeRect(const QPoint& ptCenter, int width, int height);

protected:
    QList<QToolButton*> m_btnList;
    int m_currentIndex;

    QRect   m_rects[ACTIVE_BUTTON_SIZE];
    QList<ButtonImageSet> m_btnImageList;

};

#endif // SLIDERLISTWIDGET_H
